//
// Created by hjie on 23-7-8.
//

#include <string>
#include <cstring>
#include <vector>

void ProducerData(std::vector<int> & data, int number)
{
    srand(time(NULL));
    for (int index = 0; index < number; index++)
    {
        data.push_back(rand()%20);
    }
    printf("%s : ", __func__ );
    for (auto & item : data)
    {
        printf("%d ", item);
    }
    printf("\n");
}

void RemoveValue()
{
    int number = 14;
    std::vector<int> number_data;
    ProducerData(number_data, number);
    int * array = &(*number_data.begin());
    int target_value = 10;

    int slow_index = 0;
    for (int index = 0; index < number; index++)
    {
        if (array[index] != target_value)
        {
            array[slow_index] = array[index];
            slow_index++;
        }
    }
    printf("result  data : ");
    for (auto & item : number_data)
    {
        printf("%d ", item);
    }
    printf("\n k = %d\n", (slow_index));
}

int main(int argc, const char * argv[])
{
    RemoveValue();
    return 0;
}


